#ifndef __DEBUG_H__
#define	__DEBUG_H__

#ifdef __cplusplus
extern "C" {
#endif

// #define DEBUG
#define PARAMETER

enum debug_msg_level {
    OFF     = 0,
    ERROR,
    WARNING,
    INFO,
	DEBUG,
    VERBOSE,
    MAX
};


#ifdef PARAMETER
extern int trace_level;
#undef  ac_traces
#define ac_traces(level, msg...) do {					\
    if((level) <= trace_level) {					\
      printf("\033[1;36m[DEBUG:%d] file:%s func:%s line:%d\033[1;39m\n", level, __FILE__, __FUNCTION__, __LINE__); \
      printf(msg);							\
      printf("\n");							\
    }									\
  }while(0)
#else
#define TRACE_LEVEL	INFO
#undef  ac_traces
#define ac_traces(level, msg...) do {					\
    if((level) >= TRACE_LEVEL) {					\
      printf("\033[0;31m[DEBUG] file:%s func:%s line:%d\033[0;39m\n",__FILE__, __FUNCTION__, __LINE__); \
      printf(msg);							\
      printf("\n");							\
    }									\
  }while(0)
#endif

#define pr_err(format, ...)  fprintf(stderr, format, ##__VA_ARGS__)
#define pr_info(format, ...) fprintf(stdout, format, ##__VA_ARGS__)




// 
#define PREFIX "ac"
#undef AC_PRINT
#define AC_PRINT(fmt, arg...)     \
	do {\
		if (VERBOSE <= trace_level) {\
			printf(PREFIX fmt, ##arg);\
		} \
	} while (0)

#undef AC_ERR
#define AC_ERR(fmt, arg...)     \
	do {\
		if (ERROR <= trace_level) {\
			printf(PREFIX"ERROR " fmt, ##arg);\
		} \
	} while (0)


#undef AC_WARN
#define AC_WARN(fmt, arg...)     \
	do {\
		if (WARNING <= trace_level) {\
			printf(PREFIX"WARN " fmt, ##arg);\
		} \
	} while (0)





#ifdef __cplusplus
}
#endif

#endif /* __DEBUG_H__ */
